<?php

namespace Yolo\Log;

/**
 * FileLog
 * @author lushaoming<lushaoming6@gmail.com>
 * @date 2024/1/31
 */
class ConsoleLog extends AbstractLog
{
    protected function writeLog(EnumLogLevel $level, string|array $log): void
    {
        if (is_string($log)) {
            $text = [
                'action' => 'log',
                'message' => $log,
                'data' => []
            ];
        } else {
            $text = $log;
        }

        $text['timestamp'] = time();

        $t = json_encode($text);

        $message = <<<LOG
[$level->value]: $t
LOG;

        echo $message . PHP_EOL;
    }
}